{template 'common/header'}
{if $operation == 'display'}
<a href="{php echo $this->createWebUrl('shop',array('op' =>'post'))}" class="btn btn-success"><i class="fa fa-plus"></i> 添加私塾</a>
<div class="panel panel-info" style="margin-top: 10px;">
	<div class="panel-heading">搜索</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
			<input type="hidden" name="m" value="hellozjx_mapwxapp" />
			<input type="hidden" name="do" value="shop" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
				<div class="col-sm-8 col-lg-9 col-xs-12">
					<input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}" placeholder="输入店铺名字">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
				<div class="col-sm-5 col-xs-12">
					<button class="btn btn-success"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
		</form>
	</div>
</div>
<div class="main panel panel-default">
	<div class="panel-body table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:30px;">ID</th>
					<th style="text-align: center;">显示顺序</th>					
					<th style="text-align: center;">私塾名称</th>
					<th style="text-align: center;">照片</th>
					<th style="text-align: center;">所属分类</th>
					<th style="text-align: center;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<tr>
					<td style="vertical-align: inherit;">{$item['id']}</td>
					<td style="text-align: center;vertical-align: inherit;">{$item['displayorder']}</td>
					<td style="text-align: center;vertical-align: inherit;">{$item['name']}</td>
					<td style="text-align: center;vertical-align: inherit;"><img width="100" src="{php echo tomedia($item['thumb'])}" alt=" "></td>
					<td style="text-align: center;vertical-align: inherit;">{$cates[$item['area_id']]}</td>
					<td style="text-align:center;font-size: 10px;vertical-align: inherit;">
						<a href="{php echo $this->createWebUrl('shop', array('op' => 'post', 'id' => $item['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>
						<a href="{php echo $this->createWebUrl('shop', array('op' => 'delete', 'id' => $item['id']))}" onclick="return confirm('确认删除吗？');return false;" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
</div>
{elseif $operation == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<input type="hidden" name="id" value="{$shop['id']}" />

		<div class="panel panel-default">
			<div class="panel-heading">
				信息
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="displayorder" class="form-control" value="{$shop['displayorder']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否显示</label>
					<div class="col-sm-9 col-xs-12">
						<label class='radio-inline'>
							<input type='radio' name='enabled' value='1' {if $shop['enabled']==1}checked{/if} /> 是
						</label>
						<label class='radio-inline'>
							<input type='radio' name='enabled' value='0' {if $shop['enabled']==0}checked{/if} /> 否
						</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>所属分类</label>
					<div class="col-sm-9 col-xs-12">
						<select class="form-control" name="area_id">
							<option value="0">全部</option>
							{loop $areas $row}
							<option value="{$row['id']}" {if $shop['area_id'] == $row['id']}selected{/if}>{$row['area_name']}</option>
							{/loop}
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>私塾姓名</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='name' name="name" class="form-control" value="{$shop['name']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>地图上的标记logo</label>
					<div class="col-sm-9 col-xs-12">
						{php echo tpl_form_field_image('logo', $shop['logo'])}
						<span class="help-block">标记在地图上的logo，正方形大小，推荐200像素以内</span>
					</div>
				</div>
				<div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">私塾图片</label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_form_field_image('thumb', $shop['thumb'])}
						<span class="help-block">图片推荐大小：250px * 200px</span>
                    </div>
                </div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>私塾地址</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='address' name="address" class="form-control" value="{$shop['address']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>私塾位置</label>
					<div class="col-sm-9 col-xs-12">
						{php echo tpl_form_field_coordinate('location', array('lng' => $shop['shop_lng'], 'lat' => $shop['shop_lat']))}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>电话</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='phone' name="phone" class="form-control" value="{$shop['phone']}" />
					</div>
				</div>
				<div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>详情介绍</label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_ueditor('content', $shop['content'])}
                    </div>
                </div>				
            </div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>
<script language='javascript'>
	function formcheck() {
		if ($("#name").val() == '') {
			util.message("请输入名称");
			return false;
		}
		if ($("#address").val() == '') {
			util.message("请填写地址");
			return false;
		}
		if ($("#price").val() == '') {
			util.message("请填写人均消费水平");
			return false;
		}
		return true;
	}
</script>
{else if $operation == 'comment'}
<div style="padding:15px;">
		<form action="" method="post">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:20px;text-align:center;">
						<input type="checkbox" onClick="AllCheck(this.form);">
					</th>
					<th style="width:20px;text-align:center;">ID</th>
                    <th style="width:30px;text-align:center;">用户头像</th>
                    <th style="width:50px;text-align:center;">昵称</th>
					<th style="width:80px;text-align:center;">评论内容</th>
					<th style="width:60px;text-align:center;">评论时间</th>
					<th style="width:80px;text-align:center;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $row}
					<tr>
						<td style="text-align:center;">
							<input type="checkbox" name="ids[]" value="{$row['id']}">
						</td>
						<td style="text-align:center;">{$row['id']}</td>
                        <td style="text-align:center;"><img src="{$row['avatar']}" style="width: 30px;" /></td>
                        <td style="text-align:center;">{$row['nickname']}</td>
						<td style="font-size:10px;color:#666;text-align:center;">{$row['content']}</td>
						<td style="font-size:12px;color:#666;text-align:center;">{php echo date('Y-m-d H:i:s', $row['createtime'])}</td>
                        </td>
                        <td align="center">
                        	{if $row['status'] == 1}
                        	<a href="{php echo $this->createWebUrl('comment', array('op' => 'hide', 'cid' => $row['id']))}" class="btn btn-xs btn-danger">隐藏</a>
                        	{else}
                        	<a href="{php echo $this->createWebUrl('comment', array('op' => 'show', 'cid' => $row['id']))}" class="btn btn-xs btn-success">显示</a>
                        	{/if}
                        </td>
					</tr>
				{/loop}
			</tbody>
		</table>
		<input type="submit" class="btn btn-success" onclick="return confirm('请不要勾选已显示的评论，重复批量显示已显示的评论会导致首页评论数出错，出错后需要手动进数据库调整数据！');return false;" name="show" value="批量显示">
		<input type="submit" class="btn btn-danger" onclick="return confirm('请不要勾选已隐藏的评论，重复批量隐藏已隐藏的评论会导致首页评论数出错，出错后需要手动进数据库调整数据！');return false;" name="hide" value="批量隐藏">
	</form>
		{$pager}
	</div>  
{/if}

{template 'common/footer'}